package com.dogegg.lbbopenapi.utils;


import jakarta.validation.*;

import java.util.Set;

public class ValidatorUtil {

    private static ValidatorFactory factory = Validation.buildDefaultValidatorFactory();

    public static <T> void validate(T obj) throws ValidationException {
        Validator validator = factory.getValidator();
        Set<ConstraintViolation<T>> constraintViolations = validator.validate(obj);
        if (constraintViolations.size() > 0) {
            throw new ConstraintViolationException(constraintViolations);
        }
    }


}
